unit ClassTJ3Folder;

interface

uses ClassTJ3BaseTAG, ClassTJ3PlaceMark, Contnrs;

type
  TJ3KmlFolder = class(TJ3KmlBaseTAG)
    private
      FNome:String;
      FOpen:Boolean;
      FListObj: TObjectList;
    protected
      function GetTAG:string; override;
    public
      constructor Create; Overload;
      constructor Create(const _nome:string); overload;
      destructor Destroy; override;
      function GetLines: String; override;

      function AddPlaceMark(_Obj: TJ3KmlPlaceMark):Integer;

      property Nome : string read FNome write FNome;
      property Open: Boolean read FOpen write FOpen;
  end;

implementation

{ TJ3KmlFolder }

constructor TJ3KmlFolder.Create;
begin
  FListObj := TObjectList.Create
end;

function TJ3KmlFolder.AddPlaceMark(_Obj: TJ3KmlPlaceMark): Integer;
begin
  Result := FListObj.Add(_Obj);
end;

constructor TJ3KmlFolder.Create(const _nome: string);
begin
  inherited Create;
  FNome := _nome;
  FOpen := false;
end;

destructor TJ3KmlFolder.Destroy;
begin
  FListObj.Free;
  inherited;
end;

function TJ3KmlFolder.GetLines: String;
var
 i : Integer;
begin
  Linhas.Clear;
  Linhas.Add(GetIniTAG);
  Linhas.Add('<name>' + Nome + '</name>');
  Linhas.Add('<open>' + '0' + '</open>');

  for i := 0 to FListObj.Count-1 do
  begin
    Linhas.Add(TJ3KmlPlaceMark(FListObj.Items[i]).GetLines);
  end;

  Linhas.Add(GetFimTAG);

  Result := Linhas.Text;
end;

function TJ3KmlFolder.GetTAG: string;
begin
  Result := 'Folder';
end;

end.
